package oa.dao.impl;

import java.util.List;

import oa.base.BaseDao;
import oa.dao.PressDao;
import oa.entity.Press;
import oa.exception.DaoException;

public class PressDaoImpl extends BaseDao<Press> implements PressDao {

	@Override
	public List<Press> selectAllPress() throws DaoException {
		return executeQuery("SELECT * FROM press");
	}

	@Override
	public List<Press> selectPressId(int id) throws DaoException {
		return executeQuery("SELECT * FROM press WHERE press_id=?",id);
	}

	@Override
	public List<Press> selectPressPid(int pid) throws DaoException {
		return executeQuery("SELECT * FROM press WHERE press_pid=?",pid);
	}

	@Override
	public List<Press> selectPress(int user_competence) throws DaoException {
		return executeQuery("SELECT (SELECT press_id FROM press WHERE press_id = user_press.press_id) AS press_id,(SELECT press_name FROM press WHERE press_id = user_press.press_id) AS press_name,(SELECT press_pid FROM press WHERE press_id = user_press.press_id) AS press_pid,(SELECT press_url FROM press WHERE press_id = user_press.press_id) AS press_url FROM user_press WHERE user_competence = ?",user_competence);
	}

}
